/*************************************************************************
    > File Name: test.cpp
    > Author: 茉莉玫瑰花茶
    > Mail: 19835250658@163.com 
    > Created Time: Fri 01 Aug 2025 12:14:12 AM CST
 ************************************************************************/

#include <stdio.h>
#include <unistd.h>

int gval = 100;

int main()
{
    int id = fork();
    if(id == 0)
    {
        //child
        while(1)
        {
            printf("子进程：gval: %d, &gval: %p, pid: %d, ppid: %d\n", gval, &gval, getpid(), getppid());
            sleep(1);
            gval++;
        }
    }
    else
    {
        //parent
        while(1)
        {
            printf("父进程：gval: %d, &gval: %p, pid: %d, ppid: %d\n", gval, &gval, getpid(), getppid());
            sleep(1);
        }
    }
    return 0;
}
